<style>     

</style>
<template>
	<div>
		<!-- 轮播图及正品保障部分 -->
		<goodsInfo v-bind:getProductInfoUrlAjax="data"></goodsInfo>
		<!-- 正品保障下面的详情部分 -->
		<goodsDetails v-bind:getProductInfoUrlAjax="data" v-bind:getDescriptionUrlAjax="secondData" v-on:componentCommunication="bridgeSiblingByParent"></goodsDetails>
	    <!-- 返回顶部按钮 -->
	    <back-to-top></back-to-top>
		<!-- 底部固定部分 -->
		<goodsFoot v-bind:getProductInfoUrlAjax="data" v-on:componentCommunication="bridgeSiblingByParent"></goodsFoot>
		<!-- 弹窗部分 -->
		<goodsSku v-bind:getProductInfoUrlAjax="data" v-bind:componentRelate="componentRelate" v-on:componentCommunication="bridgeSiblingByParent"></goodsSku>
	</div>  
</template>

<script>
import {TransferDom, Popup, Group, Cell ,XHeader, XInput, XButton, Box, Sticky, TabItem, Tab, XImg } from 'vux'
import goodsInfo from './default/goodsInfo.vue' 
import goodsDetails from './default/goodsDetails.vue'
import goodsSku from './default/goodsSku.vue'
import goodsFoot from './default/goodsFoot.vue'
import backToTop from '../Public/backToTop/backToTop.vue'
export default {
	components: {
    backToTop,
		goodsInfo,
		goodsDetails,
		goodsSku,
		goodsFoot,
		XImg,
		TransferDom,
		Popup,
		Group,
		Cell,
		XHeader,
		XInput,
		XButton,
		Box,
		Sticky,
		TabItem,
		Tab  
	},
	data () {
		return {
			isActive: true,
			scroll: '',
			selected: true,
			show: false,
			info: "",
			data: {},
			secondData: {},
			componentRelate: null,
		}
	},
	methods: {
		//组件通信
		bridgeSiblingByParent() {
			this.componentRelate = !this.componentRelate;
		},
	},
	mounted: function() {
		// 商品编码
		var goodsSn = this.$route.params.id;
		// 渠道编码
		var channelCode = this.$route.query.channelCode;
		// 通过this.$route.params.id这个方法，可以获取到我每个商品的id值
		if (!goodsSn) return;
		// 请求地址
		var getProductInfoUrl = window.config.interface.getProductInfo + "?goods_sn=" + goodsSn + "&channelCode=" + channelCode;
		var getDescriptionUrl = window.config.interface.getDescription + "?goods_sn=" + goodsSn + "&channelCode=" + channelCode;
		// 获取商品信息
		this.$http.jsonp(getProductInfoUrl).then(
			function(response) {
				//这里是处理正确的回调
				this.data = response.data.data.productInfo;
			}, 
			function(response) {
				// 这里是处理错误的回调
				console.log(response)
			}
		);
		// 获取商品详情
		this.$http.jsonp(getDescriptionUrl).then(
			function(response) {
				// 这里是处理正确的回调
				this.secondData = response.data.data;
			}, 
			function(response) {
				// 这里是处理错误的回调
				console.log(response)
			}
		)
	},
}
</script>





